/*
 * @description: 
 * @Author: wzg
 * @Date: 2021-03-08 08:42:12
 * @LastEditTime: 2021-03-17 15:28:52
 */
import resultEnum from '../utils/resultEnum.js';
import Mocks from '../utils/mock.js';
const Mock = new Mocks();

/* 查询地址信息 */
export function selectAddressInfo (ctx, next) {
  try {
    const params = {
      ...ctx.query
    };
    console.log(params);
    /* 模拟查询数据库，处理后返回 */
    /* 返回对象 */

    ctx.success(resultEnum.GET_SUCCESS.code, resultEnum.GET_SUCCESS.msg, Mock.getAddressList())
  } catch (error) {
    ctx.error(resultEnum.GET_ERROR.code, resultEnum.GET_ERROR.msg)
  }
}

/* 查询地址信息通过id */
export function selectAddressInfoById (ctx, next) {
  const params = {
    ...ctx.params
  };
  console.log(params);
  ctx.success(resultEnum.GET_SUCCESS.code, resultEnum.GET_SUCCESS.msg, Mock.getAddressById())
}

/* 新增地址信息 */
export function insertAddress (ctx, next) {
  const params = {
    ...ctx.request.body
  };
  console.log(params);
  ctx.success(resultEnum.SAVE_SUCCESS.code, resultEnum.SAVE_SUCCESS.msg)
}

/* 更新地址信息 */
export function updateAddress (ctx, next) {
  const params = {
    ...ctx.request.body,
    ...ctx.params
  };
  console.log(params);
  ctx.success(resultEnum.UPDATE_SUCCESS.code, resultEnum.UPDATE_SUCCESS.msg)
}

/* 删除地址信息 */
export function deleteAddress (ctx, next) {
  const params = {
    ...ctx.params
  };
  console.log(params);
  ctx.success(resultEnum.DELETE_SUCCESS.code, resultEnum.DELETE_SUCCESS.msg)
}

// export default {
//   selectAddressInfo,
//   selectAddressInfoById,
//   insertAddress,
//   updateAddress,
//   deleteAddress
// }